#ifndef CH32F103_FLASH_H
#define CH32F103_FLASH_H
#include"target_flash.h"
typedef struct
{
  volatile unsigned int ACTLR;
  volatile unsigned int KEYR;
  volatile unsigned int OBKEYR;
  volatile unsigned int STATR;
  volatile unsigned int CTLR;
  volatile unsigned int ADDR;
  volatile unsigned int RESERVED;
  volatile unsigned int OBR;
  volatile unsigned int WPR;
} FLASH_TypeDef_ch32f103;
#define ch32flash               ((FLASH_TypeDef_ch32f103 *) (0x40000000 + 0x20000 + 0x2000))
#define ch32RDP_Key                  ((uint16_t)0x00A5)
#define ch32FLASH_KEY1               ((unsigned int )0x45670123)
#define ch32FLASH_KEY2               ((unsigned int )0xCDEF89AB)
extern TargetFlash TargetFlash_t[3];
unsigned int ch32_FlashErase(unsigned int Addr,unsigned int len);
unsigned int ch32_FlashProgram(unsigned int Addr,char*buf,unsigned int len);
unsigned int FlashIsLock(unsigned int *res);
unsigned int FastFlashIsLock(unsigned int *res);
#endif
